package com.higgins.client.components;

import java.util.List;
import java.util.logging.Logger;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.higgins.client.GreetingService;
import com.higgins.client.GreetingServiceAsync;
import com.higgins.client.dataModel.CoveringLetterDTO;
import com.higgins.client.dataModel.SectorDTO;
import com.higgins.client.generic.components.GenericColumn;

public class SectorColumn extends GenericColumn		{
	private static final Logger log = Logger.getLogger(SectorColumn.class.getName());
	private final GreetingServiceAsync greetingService = GWT
			.create(GreetingService.class);

	public void loadList()	{
	    retrieveSectorDTOs();
		
	}
	private void retrieveSectorDTOs()	{
		try {
			greetingService.retrieveSectors(new AsyncCallback<List<SectorDTO>>()	{
					@Override
					public void onFailure(Throwable caught) {
						log.info("StrategyColumns: " + caught.toString());
					}

					@Override
					public void onSuccess(List<SectorDTO> result) {
//						List<String> list = new ArrayList<String>();
//						for (CoveringLetterDTO coveringLetterDTO:result)	{
//							list.add(coveringLetterDTO.getName());
//						}
						setList(result);
					}
				});
		} catch (IllegalArgumentException e) {
			log.info("StrategyColumns: " + e.toString());
		}	}		
}
